package chamber.two.christmastown;

import com.google.common.util.concurrent.AbstractScheduledService;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

import java.util.concurrent.TimeUnit;

/**
 * Created by Gerardo on 1/3/14.
 */
public class ReindeerImpl extends AbstractScheduledService implements Reindeer {
    private final String name;

    @Inject
    public ReindeerImpl(@Assisted final String name) {
        this.name = name;
    }

    @Override
    protected void runOneIteration() throws Exception {
        System.out.println("Soy " + name + " y ya llegue.");
        shutDown();
    }

    @Override
    protected Scheduler scheduler() {
        return Scheduler.newFixedDelaySchedule(10, 1, TimeUnit.SECONDS);
    }

}
